# -*- encoding: utf-8 -*-
import os,sys,time

thispath = os.path.abspath(__file__)# get the module path!
parentdir,f = os.path.split(thispath)

msnppath = os.path.join(parentdir,"msnp.zip")
sys.path.append( msnppath )
import msnp

class MsnChatListener(msnp.ChatCallbacks):
    def message_received(self, passport_id, display_name, text, charset):
        print 'receive'
        print '%s: %s' % (passport_id, text)
        self.chat.send_message(text, charset)

class MsnListener(msnp.SessionCallbacks):
    def chat_started(self, chat):
        print 'start chat'
        callbacks = MsnChatListener()
        chat.callbacks = callbacks
        callbacks.chat = chat


msns = msnp.Session(MsnListener())
try:
    msns.login('linux_23@163.com','020308')

    print u'登陆成功'

except:
    print u'登陆失败，查看网络，或者查看用户名密码'
    sys.exit(0)
msns.sync_friend_list() 
while True:
    msns.process(chats = True)
    #time.sleep(1)
    print 1
    
